package com.unit5;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author 李琦 on 2021/8/12.
 * @version java version "16.0.1" 2021-04-20
 * 打印流:PrintWriter    PrintStream
 *
 */
public class test7 {
    public static void main(String[] args) {
        //打印到控制台输出
//        String s="hello,world";
//        PrintWriter pw=new PrintWriter(System.out);
//        pw.println(s);
//        pw.close();//必须加

        //打印到文件
        PrintWriter pw=null;
        try {
            pw=new PrintWriter(new FileWriter("E:\\padata\\你好.txt",true));
            pw.println("hello,world");
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            pw.close();
        }

    }

}
